package com.hhxyjsj.framework.logging.support;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 日志组件的默认实现类
 * 
 * @author hhxyj
 *
 */
public class DefaultLoggerImpl implements com.hhxyjsj.framework.logging.Logger {
	
	private String clazzName;
	
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	public DefaultLoggerImpl(Class<?> clazz){
		this.clazzName = clazz.getName();
	}

	@Override
	public void info(String sourceMethod,String params,String rvtObjs){
		String msg = String.format("%s class %s method %s agrs %s returnVal %s", sdf.format(new Date()),clazzName,sourceMethod,params,rvtObjs);
		System.out.println(msg);
		try {
			LogManager.append(msg);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void info(String msg) {
		try {
			LogManager.append(msg);
		} catch (IOException e) {
			e.printStackTrace();
		}		
	}
	
}
